package com.map.hashmap;


import java.util.HashMap;
import java.util.Map;

class Em{
	public String fname;
	public String lname;
	public Em(String fname, String lname){
		this.fname = fname;
		this.lname = lname;
		//System.out.println("empl()");
	}
	public boolean equals(Object obj){
		System.out.println("equals");
		Em e = (Em)obj;
		return this.fname==e.fname&&this.lname==e.lname;
	}
	public int hashcode(){
		System.out.println("hashcode()");
		int hash = fname.hashCode();
		hash = hash+ lname.hashCode();
		return hash;
	}
	@Override
	public String toString() {
		return fname + " " + lname;
	}
}

public class MapExample {
	public static void main(String[] args) {
		Map<Integer,Em> map = new HashMap<Integer, Em>();
		map.put(1,new Em("Hare","ram"));
		map.put(2,new Em("Raghu","raj"));
		map.put(3,new Em("Bindu","Singh"));
		map.put(4,new Em("Hare","ram"));
		System.out.println(map);
		System.out.println(map.size());
		
		map = new HashMap<Integer, Em>();
		map.put(1,new Em("Hare","ram"));
		map.put(2,new Em("Raghu","raj"));
		map.put(3,new Em("Bindu","Singh"));
		map.put(1,new Em("Hare","ram"));
		System.out.println(map);
		System.out.println(map.size());
		
		Map<Em, Integer> map1 = new HashMap<Em,Integer>();
		map1.put(new Em("Hare","ram"),12);
		map1.put(new Em("Raghu","raj"),23);
		map1.put(new Em("Bindu","Singh"),34);
		map1.put(new Em("Hare","ram"),45);
		System.out.println(map);
		System.out.println(map.size());
		
	}
}

